package com.yuqing.myblogServe.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yuqing.myblogServe.dao.entity.Article;
import com.yuqing.myblogServe.dao.entity.ArticleLikesRecord;
import com.yuqing.myblogServe.dao.mapper.ArticleLikesRecordMapper;
import com.yuqing.myblogServe.dao.mapper.ArticleMapper;
import com.yuqing.myblogServe.service.ArticleLikesRecordService;
import com.yuqing.myblogServe.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author lyq
 * @date 2023/12/7
 **/

@Service
public class ArticleLikesRecordServiceImpl extends ServiceImpl<ArticleLikesRecordMapper, ArticleLikesRecord> implements ArticleLikesRecordService {
    @Autowired
    ArticleLikesRecordMapper articleLikesRecordMapper;


    @Override
    public boolean isLike(String articleId, Long likerId) {
        Long count = articleLikesRecordMapper.selectCount(new QueryWrapper<ArticleLikesRecord>().
                eq("article_id", articleId).eq("liker_id", likerId));

        if(count > 0) {
            return count > 0;
        }
        return false;
    }

    @Override
    public void insertArticleLikesRecord(ArticleLikesRecord articleLikesRecord) {
        articleLikesRecordMapper.insert(articleLikesRecord);

    }


    @Override
    public void deleteArticleLikesRecordByArticleId(String articleId) {


    }
}
